#include <bits/stdc++.h>
using namespace std;
int N;
char c[10], d[10];
int main()
{

	while (scanf("%s %s", c, d) != EOF)
	{
		int t1 = (c[3] - '0') * 10 + c[4] - '0';
		int t2 = (d[3] - '0') * 10 + d[4] - '0';
		if (t1 == 0)
			t1 = 60;
		if (t2 == 0)
			t2 = 60;
		int cnt = 0;
		if (t1 >= 30 && t1 <= 40)
		{
			if (t2 >= 30 && t2 <= 40)
			{
				cnt += (t2 - t1) * 100;
			}
			else if (t2 >= 40 && t2 <= 50)
			{
				cnt += (40 - t1) * 100;
				cnt += (t2 - 40) * 150;
			}
			else if (t2 >= 50 && t2 <= 60)
			{
				cnt += (40 - t1) * 100 + 10 * 150;
				cnt += (t2 - 50) * 50;
			}
		}
		else if (t1 >= 40 && t1 <= 50)
		{
			if (t2 >= 40 && t2 <= 50)
			{
				cnt += (t2 - t1) * 150;
			}
			else if (t2 >= 50 && t2 <= 60)
			{
				cnt += (50 - t1) * 150;
				cnt += (t2 - 50) * 50;
			}
		}
		else if (t1 >= 50 && t1 <= 60)
		{
			cnt += (t2 - t1) * 50;
		}
		cout << cnt << endl;
	}
	return 0;
}
